<template>
  <el-drawer
    :title="title"
    :visible.sync="visible"
    :size="size"
    :before-close="modelClose"
    :wrapper-closable="false"
  >
    <div class="box-query-form">
      <el-form :model="queryParam" label-width="auto" label-position="right" :gutter="24">
        <el-row>
          <el-col :xl="12" :lg="12" :md="12" :sm="24">
            <el-form-item label="评语:">
              <el-input v-model="queryParam.remark" placeholder="请输入" />
            </el-form-item>
          </el-col>
          <el-col :xl="12" :lg="12" :md="12" :sm="24" class="table-search-btn">
            <el-button icon="el-icon-refresh" @click="searchReset">重置</el-button>
            <el-button type="primary" icon="el-icon-search" @click="searchQuery">查询</el-button>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <!-- 批量操作 -->
    <div v-if="selectedRowList.length" class="batchAction">
      <div class="batchAction-left">
        <el-dropdown>
          <el-button>
            批量操作 <i class="el-icon-arrow-down el-icon--right" />
          </el-button>
          <el-dropdown-menu slot="dropdown">
            <el-dropdown-item>
              <div @click="batchDelete"><i class="el-icon-delete" />删除</div>
            </el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
      </div>
      <div class="batchAction-right">
        已选择
        <span style="font-weight: 700">
          <el-link type="primary" :underline="false">{{ selectedRowList.length }}</el-link>
        </span>项
        <el-link type="primary" :underline="false" style="margin-left: 24px;" @click="onClearSelected">清空</el-link>
      </div>
    </div>
    <el-table ref="table" :data="dataSource" @selection-change="onSelectChange">
      <el-table-column type="selection" width="55" />
      <el-table-column fixed="left" prop="id" label="ID" width="70" />
      <el-table-column prop="classs" label="分类" min-width="120" />
      <el-table-column prop="remark" label="评语" min-width="200">
        <template slot-scope="scope">
          <div :title="scope.row.remark" class="overflow2">{{ scope.row.remark }}</div>
        </template>
      </el-table-column>
      <el-table-column prop="updateTime" label="更新时间" width="170" />
      <el-table-column fixed="right" label="操作" width="150">
        <template slot-scope="scope">
          <el-button type="text" @click="handleEdit('查看', scope.row, true)">查看</el-button>
          <el-button type="text" @click="handleEdit('编辑', scope.row)">编辑</el-button>
          <el-popconfirm title="确定删除吗？" style="margin-left: 10px" @confirm="handleDelete(scope.row[guidFieldName])">
            <el-button slot="reference" type="text" style="color: red;">删除</el-button>
          </el-popconfirm>
        </template>
      </el-table-column>
    </el-table>
    <div class="box-paging">
      <Pagination
        v-show="ipagination.total > 0"
        layout="total, sizes, prev, pager, next"
        :total="ipagination.total"
        :page.sync="ipagination.pageNum"
        :limit.sync="ipagination.pageSize"
        @pagination="loadData"
      />
    </div>
    <handleDrawer ref="modalForm" @ok="modalFormOk" />
  </el-drawer>
</template>

<script>
import { postAction } from '@/api/manage'
import { listMixin } from '@/mixins/listMixin'
import Pagination from '@/components/Pagination'
import handleDrawer from './handleDrawer'

export default {
  components: {
    handleDrawer,
    Pagination
  },
  mixins: [listMixin],
  props: {},
  data() {
    return {
      guidFieldName: 'id',
      model: {},
      visible: false,
      disableMixinCreated: true,
      title: '',
      ipagination: {
        pageNum: 1,
        pageSize: 100,
        total: 0
      },
      classs: '',
      size: '50%',
      url: {
        list: 'evaluateList.aspx?action=GetList',
        delete: 'evaluateList.aspx?action=Delete',
        deleteBatch: 'evaluateList.aspx?action=DeleteBatch'
      }
    }
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {},
  methods: {
    show(rowData) {
      this.visible = true
      this.classs = rowData.classs
      this.loadData(1)
    },
    // 添加查询参数 默认加空对象
    addQueryParams() {
      return {
        classs: this.classs
      }
    },
    handleEdit(title, rowData, disableSubmit) {
      this.$refs.modalForm.edit(rowData)
      this.$refs.modalForm.title = title
      this.$refs.modalForm.disableSubmit = disableSubmit
    },
    get() {
      this.$store.dispatch('app/setLoading', true)
      postAction(this.url.update, this.model).then((res) => {
        if (res.code === 1) {
          this.modelClose()
          this.$message.success(res.message || '操作成功！')
          this.$emit('ok')
        } else {
          this.$message.warning(res.message || '操作失败！')
        }
      }).finally(() => {
        this.$store.dispatch('app/setLoading', false)
      })
    },
    modelClose() {
      this.visible = false
    }
  }
}
</script>

<style lang="scss" scoped>
.updateForm{
  padding: 20px 30px 0;
  margin-bottom: 90px;
  ::v-deep .el-form-item__label{
    line-height: 16px;
  }
}
.el-col{
  padding: 0 8px;
}
.drawer-footer{
  position:absolute;
  bottom:0;
  left:0;
  display:flex;
  align-items:center;
  justify-content:flex-end;
  width:100%;
  height:65px;
  background:#fff;
  z-index:999;
  padding: 16px 29px;
  box-shadow: 0px -1px 16px 1px rgba(0,0,0,0.08);
  border-radius: 4px 4px 4px 4px;
  opacity: 1;
}
::v-deep .el-drawer__body {
    overflow: auto;
}
$batchActionHeight: 35px; //批量操作行高
// 批量操作
.batchAction {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: $batchActionHeight;
  margin-bottom: 10px;
  padding: 0 20px;

  .batchAction-left {
    width: 130px;
    height: 100%;
    line-height: $batchActionHeight;
  }

  .batchAction-right {
    flex: 1;
    padding-left: 50px;
    border-radius: 3px;
    border: 1px solid #91d5ff;
    background-color: rgba(24, 145, 255, 0.15);
    height: 100%;
    line-height: $batchActionHeight;
    color: #505659;

    .el-link {
      vertical-align: bottom;
    }
  }
}
</style>
